package com.cskaoyan.service.vx;

import com.cskaoyan.bean.po.wxPo.MarketCategory;
import com.cskaoyan.bean.vo.vxVo.CatalogIndexVo;
import com.cskaoyan.bean.vo.vxVo.CatalogVo;
import com.cskaoyan.mapper.wxMapper.MarketCategoryMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author: DYQ
 * @time: Created on 2022/6/7 21:32
 */

@Service
public class CatalogServiceImpl implements CatalogService{

    @Autowired
    MarketCategoryMapper marketCategoryMapper;

    @Override
    public CatalogVo queryCurrentCatalog(Integer id) {
        MarketCategory marketCategory = marketCategoryMapper.selectById(id);
        List<MarketCategory> marketCategories = marketCategoryMapper.selectCategoryByPid(id);
        CatalogVo catalogVo = new CatalogVo();
        catalogVo.setCurrentCategory(marketCategory);
        catalogVo.setCurrentSubCategory(marketCategories);
        return catalogVo;
    }

    @Override
    public CatalogIndexVo queryCatalogIndex() {
        List<MarketCategory> marketCategories = marketCategoryMapper.selectCategoryByLevel();
        MarketCategory marketCategory = marketCategories.get(0);
        MarketCategory marketCategory1 = marketCategoryMapper.selectById(marketCategories.get(0).getId());
        List<MarketCategory> marketCategories1 = marketCategoryMapper.selectCategoryByPid(marketCategory.getId());
        CatalogIndexVo catalogIndexVo = new CatalogIndexVo();
        catalogIndexVo.setCurrentCategory(marketCategory1);
        catalogIndexVo.setCategoryList(marketCategories);
        catalogIndexVo.setCurrentSubCategory(marketCategories1);
        return catalogIndexVo;
    }
}
